11. Android Software Stack

Introduce Android Software Stack & Gradle

Advanced Build Options

Gradle in Android Studio

Gradle is the build system of choice for Android Studio. Because of that, there's various functionality available within the platform. When you make a project, there are a few gradle build scripts automatically generated for you, shown below:

When you press the green Run button, if the project has changed, the build scripts will run.

To explicitly run the build scripts, you can press the Make Project button:

To observe logs and build errors for gradle, Android Studio includes a Gradle Console.

A gradle task represents a single, atomic piece of work for a build. To see a list of tasks, you can open the tasks window in Android Studio by clicking on the gradle button on the far right. Clicking on the name of the task runs that task.

Gradle from the Command Line

You can also run gradle build tasks from the command line if you prefer. To start, you should navigate to the root of your project folder. From there you can run:

./gradlew tasks

This will give you a full list of runnable tasks. You may need to run chmod +x on gradlew before you can run it. See this link for more detailed instructions. To learn more, you can check out Udacity's Gradle course.

Android Debug Bridge

The other tool that Dan mentioned is adb which is short for Android Debug Bridge. ADB is a command line utility included with Android's SDK. You do not need to use adb for this course, but if you enjoy using the command line, you can read up on adb and other command line tools.

When you type adb into a terminal, you'll also get a helpful list of everything adb can do for you:

For example, to start your android app from the command line, you could type:

adb shell am start -n com.package.name/com.package.name.ActivityName